package com.example.mvplibrary.adapter;

import android.content.Context;
import android.view.ViewGroup;

import java.util.List;

/**
 * 项目名：p7_2_zong
 * 包名： com.example.mvplibrary.adapter
 * 文件名：MultipleAdapter
 * 创建者：朱勇闯
 * 创建时间：2021/3/18  15:47
 * 描述：TODO
 */
public abstract class MultipleAdapter<DATA> extends BaseAdapter<DATA> {
    private CommType<DATA> commType;
    protected int type = -1;

    public MultipleAdapter(List<DATA> datas, Context context, CommType<DATA> commType) {
        super(datas, context, 0);
        this.commType = commType;
    }


    @Override
    public int getItemViewType(int position) {
        type = commType.getType(position, datas.get(position));
        return type;
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        int typeLayout = commType.getTypeLayout(viewType);
        return new BaseViewHolder(layoutInflater.inflate(typeLayout, parent, false));
    }


}
